//定义变量 字符串类型
var a = "jiangxi"
let b = "jiujiang"

// 定义数值
var a1 = 1
let a2 = 2

//布尔类型
var f1 = true
let f2 = false

//定义空对象 引用类型
var obj1 = {}
let obj2 = {}

//定义空对象
var obj3 = new Object()
let obj4 = new Object()

//给空对象增加属性 属性名：属性值
var student = {
    username: "zhansgan",
    password: "133",
    gender: "male",
    age: 21,
    flag: true,

}
console.log(student.username)
console.log(student.age);

//定义对象

let obj5 = new Object()
obj5.appName = "微信";
obj5.appPrice = 50;
obj5.appAuthor = "李四";
obj5.appstatus = ture;
console.log(obj5.appPrice);


//给student对象增加地址属性
student.address = "jiangxijiujiang"
console.log(student.address);



//定义一个普通函数
function addPerson() {

}
//定义普通函数
function cla(a, b) {
    console.log(a + b);

}
// 运行函数  函数执行 函数调用
cla(3, 4)

//定义普通函数
function printlog(a, b, c = 3) {
    console.log(a + b + c);

}//调用
printlog(1, 2, 4)

//定义普通函数 有返回值
function getnumber() {
    return 2;
}
console.log(getnumber())

//
function getvalue(a, b) {
    return a + b;
} console.log(getvalue(1, 2))


// 定义对象 属性名：属性值
var personInfor = {
    username: "zahnsgan",
    age: 19,
    score: [80, 85, 88]
}

function getSum(o) {
    let sum = 0;
    for (let index = 0; index < o.score.length; index++) {
        sum = sum + o.score[index];

    }
    return sum;
}
console.log(getSum(personInfor))

//升级
var fruitobj = {
    fruitName: "赣南脐橙",
    fruitPrice: 299,
    fruitColor: ["red", "bule", "yellow"],
    price: function getPrice() {
        return this.fruitPrice
    },
    colorCount: function getcolorCount() {
        return this.fruitColor.length;
    }
}
console.log(fruitobj.price())

//普通函数
function getFruitInfo(){
    return 2+2;
}
// 匿名函数
let f4= function(){
    return 2+2;
 }
 f4()
//箭头函数
let f5 = ()=>{
    return 2+2;
}
f5()
//
let f6 = (a)=>{
console.log(a.username);
}
f6({username:"zhansgan"})

//传匿名函数
let f7= (b)=>{
    b()
}
f7(function abc(){
    console.log("this is f7");
    
})